package org.neuedu.ssmp.crm.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.*;
import org.neuedu.ssmp.crm.entity.OrderList;
import org.neuedu.ssmp.crm.entity.Orders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author MoonHolder
 * @since 2019-12-09
 */
public interface OrdersMapper extends BaseMapper<Orders> {

    List<Orders> queryTime();

    @Results({
            @Result(id = true, property = "productId", column = "product_id"),
            @Result(property = "productName", column = "product_id", one = @One(select = "org.neuedu.ssmp.crm.mapper.OrdersMapper.findProductById"))
    })
    @Select("select id, order_id, product_id, quantity, price, amount from order_list ${ew.customSqlSegment}")
    IPage<OrderList> conditionPage(IPage<OrderList> page, @Param(Constants.WRAPPER) Wrapper<OrderList> wrapper);

    @Select("select name from product where id = #{productId};")
    String findProductById(int productId);

    List<Integer> cId();

}
